/**
 * Extends2.java
 * Rewrite the Java program extends2 presented in the Course Documents section 
 * to include a Daughter which is inherited from the Parent class. 
 * 
 * Code a Daughter method that automatically increases her size to +1 of the 
 * current Son size and then decreases the Son size by 2. 
 * 
 * Compile and Run the program.
 *
 * @author  John Thomason
 *    Date: Nov 16, 2008
 *  Course: CS221 Introduction to Java Programming
 * Seminar: 2
 *  Assign: 3
 */

/**
 * Extends2 Class
 * - Description
 */
public class Extends2 {

  /**
   * Application Entry Point
   * @param args The command line arguments
   */
  public static void main(String[] args) {
 
       Son joe = new Son();
       joe.bumpsize();    // call to the parent method
       System.out.println(" joe Son size is " + joe.size);
       joe.jumpsize();    // call to the son method
       
       Parent bill = new Parent(15);
       System.out.println(" Parent bill size is " + bill.size);
       bill.bumpsize();
    
       Daughter emy = new Daughter();   //Daughter set to default size
       System.out.println(" Daughter Emy's size is " + emy.size );
       emy.dumpsize(joe);               //Emy takes advantage of joe |-{
       System.out.println(" Brother Joe's size is " + joe.size);

  }//End main()

}//End Extends2 Class


/******************************************************************************
 * Parent Class
 */
class Parent {
  
  //Child classes can directly access this property
  protected int size;

  //Constructors
  Parent() {
    size = 7;         //Default child size
  }
  //Overloaded Constructor
  Parent(int size) {
    this.size = size;
  }

  //Increase size by one(1)
  void bumpsize(){
    size++;
    System.out.println();
    System.out.println("Parent size is " + size);
  }//end bumpsize()

}//end Parent


/******************************************************************************
 * Son Class
 */
class Son extends Parent {   //Son is a subclass of Parent

  //Increase Son's size by two(2)
  void jumpsize(){
    size = ++size + 1;
    System.out.println("Son size is now " + size);
  }//end jumpsize()
  
}// end Son


/******************************************************************************
 * Daughter Class
 */
class Daughter extends Parent {
  
  //Increase the Daughter size by the Son size plus one(1)
  //Decrease Son size by two
  void dumpsize(Son brother){
    this.size    += (brother.size + 1);
    brother.size -= 2;
    System.out.println("Daughter size is now " + size);
  }//end dumpsize()
  
}// end Daughter